# coding: utf-8

import sys
sys.path.append('../3_data_structure')
from stack import Stack

parentheses1 = '(())'
parentheses2 = '(()))'


def check_balanced_parentheses(input_string):
    stack = Stack()

    for item in input_string:
        if item == '(':
            stack.push(item)
        elif item == ')':
            if stack.is_empty():
                return False
            else:
                stack.pop()

    return stack.is_empty()


print(check_balanced_parentheses(parentheses1))
print(check_balanced_parentheses(parentheses2))
